import { IParam, EntityBase } from '@/core';
import { IAuth } from './interface/i-auth';
import AuthKeys from './auth-keys';

/**
 * 登录信息基类
 * 基于template/src/api/{{appEntities}}/{{appEntities}}-base.ts.hbs生成
 *
 * @export
 * @abstract
 * @class AuthBase
 * @extends { EntityBase }
 * @implements { IAuth }
 */
export abstract class AuthBase extends EntityBase implements IAuth {
	/**
	 * 实体名称
	 *
	 * @readonly
	 * @type {string}
	 * @memberof AuthBase
	 */
	get srfdename(): string {
		return 'AUTH_LOGIN';
	}

	/**
	 * 当前实体所有属性
	 *
	 * @protected
	 * @type {string[]}
	 * @memberof AuthBase
	 */
	protected get keys(): string[] {
		return AuthKeys;
	}

	/**
	 * Creates an instance of ConstactOppoBase.
	 * @param {*} [data]
	 * @memberof AuthBase
	 */
	constructor(data?: any) {
		super();
		this.setData(data);
	}

	get srfkey(): string {
		return this.id;
	}

	set srfkey(val: string) {
		this.id = val;
	}

	/**
	 * 标识
	 **/
	id?: any;

	get srfmajortext(): string {
		return this.login_name;
	}

	set srfmajortext(val: string) {
		this.login_name = val;
	}
	/**
	 * 登录名
	 **/
	login_name?: any;

	/**
	 * 密码
	 **/
	password?: any;

	/**
	 * DC
	 **/
	dc?: any;

	/**
	 * token类型
	 **/
	token_type?: any;

	/**
	 * access_token
	 **/
	access_token?: any;

	/**
	 * token
	 **/
	token?: any;

	/**
	 * 用户信息
	 **/
	user?: any;

	/**
	 * 范围
	 **/
	scope?: any;

	/**
	 * token_id
	 **/
	token_id?: any;

	/**
	 * 过期时间
	 **/
	expiration?: any;

	/**
	 * 过期剩余秒数
	 **/
	expires_in?: any;

	/**
	 * refresh_token
	 **/
	refresh_token?: any;

	/**
	 * 验证码标识
	 **/
	state?: any;

	/**
	 * 验证码
	 **/
	code?: any;

	/**
	 * 变更的新密码
	 **/
	new_password?: any;

	/**
	 * 手机号
	 **/
	phone?: any;

	/**
	 * 验证码图片
	 **/
	image?: any;

	/**
	 * 登录类型
	 **/
	login_type?: any;

	/**
	 * 名称
	 **/
	display_name?: any;

	/**
	 * 重置实体数据
	 *
	 * @param {IParam} [data={}]
	 * @memberof AuthBase
	 */
	reset(data: IParam = {}): void {
		super.reset(data);
		this.id = data.id || data.srfkey;
		this.login_name = data.login_name || data.srfmajortext;
	}
}
